package com.example.java_chatroom.Controller;

import com.example.java_chatroom.model.GroupChat;
import com.example.java_chatroom.model.Result;
import com.example.java_chatroom.service.GroupChatService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RequestMapping("/GroupChat")
@RestController
public class GroupChatController {
    @Autowired
    private GroupChatService groupChatService;

    @RequestMapping("/SetTitle")
    public Result SetTitle(Integer sessionId, String title) {
        groupChatService.UpdateTitle(sessionId, title);
        return Result.success(1);
    }
    @RequestMapping("/GetTitle")
    public Result GetTitle(Integer sessionId) {
      GroupChat groupChat = groupChatService.queryByTitle(sessionId);
        return Result.success(groupChat);
    }
}
